#include "../src/include/DemoDAO.h"
#include <cassert>
#include <iostream>

void testDemoDAO() {
    std::string conn_string = "dbname=testdb user=postgres password=123456 host=localhost port=5432";
    
    DemoDAO dao(conn_string);
    
    // 测试连接
    assert(dao.isConnected());
    
    // 测试创建表
    assert(dao.createTable());
    
    // 测试插入数据
    int id = dao.insertData("Test data");
    assert(id > 0);
    
    std::cout << "All tests passed!" << std::endl;
}

int main() {
    try {
        testDemoDAO();
        return 0;
    } catch (const std::exception& e) {
        std::cerr << "Test failed: " << e.what() << std::endl;
        return 1;
    }
}